package com.hdu.careerplan.pojo.vo;

import com.hdu.careerplan.pojo.pythonData.TechListData;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
public class TechListDataVO {

    @AllArgsConstructor
    @Data
    public static class TechRate {

        private final String techName;

        private final Double rate;

    }

    private String region;  // 地区

    private String jobName; // 岗位名字

    private List<TechRate> techRateList;  // 公司列表

    public TechListDataVO(TechListData techListData) {
        this.region = techListData.getRegion();
        this.jobName = techListData.getJobName();
        Map<String, String> techRate = techListData.getTechRate();
        ArrayList<TechRate> techRateList = new ArrayList<>();
        for (String techName : techRate.keySet()) {
            String rateStr = techRate.get(techName);
            double rate = Double.parseDouble(rateStr.substring(0,rateStr.length()-1));
            techRateList.add(new TechRate(techName, rate));
        }
        this.techRateList = techRateList;

    }

    public TechListDataVO(String region, String jobName, List<String> list) {
        this.region = region;
        this.jobName = jobName;
        ArrayList<TechRate> techRateList = new ArrayList<>();
        for (int i = 0; i < list.size() / 2; i++) {
            String techName = list.get(i);
            double rate = Double.parseDouble(list.get(i + 10).substring(0, list.get(i + 10).length() - 1));
            techRateList.add(new TechRate(techName, rate));
        }
        this.techRateList = techRateList;


    }


}
